use bd_sync_rs::api::BaiduNetDisk;
use std::env;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let args: Vec<String> = env::args().collect();
    if args.len() != 4 {
        eprintln!("Usage: {} <access_token> <local_path> <remote_path> <access_token>", args[0]);
        std::process::exit(1);
    }
    // 单个文件上传静态地址
    const API_ENDPOINT: &str = "https://c.pcs.baidu.com/rest/2.0/pcs/file";
    let uploader = BaiduNetDisk::new(API_ENDPOINT, &args[1]);
    match uploader.upload_file(&args[2], &args[3]).await {
        Ok(response) => {
            println!("文件上传成功,百度网盘路径: '{}', 响应: '{}'", &args[3], response);
            std::process::exit(0);
        }
        Err(e) => {
            eprintln!("文件上传失败,错误信息: {}", e);
            std::process::exit(1);
        }
    }
}
// 运行示例
// cargo run --example upload -- YOUR_ACCESS_TOKEN ./local/path/file /remote/path/
// cargo run --example upload 121.b77278df38bc8a27c7e41c7fa6f9aab4.YC85pElXfHmFPN5YAWKHhbzmGwUQ3NTlguJTtzx.8cyJPA /home/autumner/Documents/rustnet/bd_sync_rs/examples/1.png /apps/bypy/